<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 继承:子类拥有父类的方法
        class Person{
            constructor(name,age,sex){
                this.name=name;
                this.age=age;
                this.sex=sex;
            }
            eat(){
                console.log(`我${this.name}特别爱吃麻辣烫`);
            }
            run(){
                console.log(`我${this.name}非常能跑`);
            }
            sleep(){
                console.log(`我${this.name}一天睡觉至少8个小时`);
            }
        }
        // 子类  继承父类
        class Student extends Person{
            constructor(id,name,age,sex){
                super(name,age,sex);
                this.id=id;
            }
        }
        // 实例化
        var s1=new Student("1","杰哥",30,"男");
        s1.eat();
        s1.run();
        s1.sleep();
    </script>
</body>
</html>